package com.mti.flexmusicplayer.model
{
	import com.mti.flexmusicplayer.Tools;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.media.Sound;

	public class MusicModel extends EventDispatcher
	{
		public function MusicModel(sound:Sound, filename:String)
		{
			_sound = sound;
			_filename = filename;
		}
		
		private var _sound:Sound;
		public function get sound():Sound
		{
			return _sound;
		}
		
		private var _filename:String;
		
		[Bindable(event="authorChange")]
		public function get author():String
		{
			return sound.id3.artist;
		}
		
		public function get title():String
		{
			return sound.id3.songName;
		}

		public function get length():int
		{
			return sound.length;
		}
		
		override public function toString():String
		{
			if ((Tools.isNullOrEmpty(title) == true) || (Tools.isNullOrEmpty(author) == true))
				return _filename;
			return title + " - " + author;
		}
	}
}